package com.example.repository;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.entity.Params;
import com.example.entity.Users;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface UsersMapper extends BaseMapper<Users> {
    void addUser(Users users);

    List<Users> findBySearchOfUsers(@Param("params")Params params);

    @Select("select * from graduation.users where identity = #{identity} and user_name = #{userName} limit 1")
    Users findUserByIdentityAndUsername(@Param("identity") String identity,@Param("userName") String userName);

    @Select("select * from graduation.users where user_name = #{userName} and identity = #{identity} and password = #{password} limit 1")
    Users findUserByIdentityAndUsernameAndPassword(@Param("identity") String identity, @Param("userName") String userName, @Param("password") String password);

    @Select("SELECT device_id FROM graduation.user_device WHERE user_id = #{userId}")
    List<String> findDeviceIdsByUserId(Long userId);
}
